home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PRIVATE.ZIP / _GETCOLS.C < prev    next >
Text File  |  1992-11-21  |  2KB  |  73 lines

  1. #define        CURSES_LIBRARY  1
  2. #include <curses.h>
  3.  
  4. #ifndef        NDEBUG
  5. char *rcsid__getcols = "$Header: c:/curses/private/RCS/_getcols.c%v 2.0 1992/11/15 03:24:24 MH Rel $";
  6. #endif
  7.  
  8.  
  9.  
  10.  
  11. /*man-start*********************************************************************
  12.  
  13.   PDC_get_columns()    - return width of screen/viewport.
  14.  
  15.   PDCurses Description:
  16.        This is a private PDCurses function
  17.  
  18.        This function will return the width of the current screen.
  19.  
  20.   PDCurses Return Value:
  21.        This routine will return OK upon success and otherwise ERR will be
  22.        returned.
  23.  
  24.   PDCurses Errors:
  25.        There are no defined errors for this routine.
  26.  
  27.   Portability:
  28.        PDCurses        int     PDC_get_columns( void );
  29.  
  30. **man-end**********************************************************************/
  31.  
  32. int    PDC_get_columns(void)
  33. {
  34. #ifdef FLEXOS
  35.        return( vir.vc_size.rs_ncols );
  36. #endif
  37. #ifdef DOS
  38. /*     short far*      CRT_COLS;*/
  39.        int             cols;
  40.        char *env_cols;
  41.  
  42. /*     CRT_COLS = (short far *) 0x044aL;*/
  43. /*     cols = *CRT_COLS;*/
  44.  
  45. /* use the value from COLS environment variable, if set. MH 10-Jun-92 */
  46. /* and use the minimum of COLS and return from int10h    MH 18-Jun-92 */
  47.        regs.h.ah = 0x0f;
  48.        int86(0x10, ®s, ®s);
  49.        cols = (int)regs.h.ah;
  50.        env_cols = (char *)getenv("COLS");
  51.        if (env_cols != (char *)NULL)
  52.        {
  53.                cols = min(atoi(env_cols),cols);
  54.        }
  55.        return(cols);
  56. #endif
  57. #ifdef OS2
  58.        VIOMODEINFO modeInfo;
  59.        int cols;
  60.        char *env_cols;
  61.  
  62.        modeInfo.cb = sizeof(modeInfo);
  63.        VioGetMode(&modeInfo, 0);
  64.        cols = modeInfo.col;
  65.        env_cols = (char *)getenv("COLS");
  66.        if (env_cols != (char *)NULL)
  67.        {
  68.                cols = min(atoi(env_cols),cols);
  69.        }
  70.        return(cols);
  71. #endif
  72. }
  73.